<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="editclients.aspx.cs" Inherits="editclients" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        #left-side
        {
            float: left;
            width: 49%;
        }

        #right-side
        {
            float: right;
            width: 50%;
        }
                
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div id="left-side">
        <div class="div-box" style="text-align:center">
            <asp:TextBox ID="tbSearch" runat="server" Width="300px" />
            <ajax:TextBoxWatermarkExtender ID="weSearch" runat="server" TargetControlID="tbSearch" WatermarkText="search by name or number" />
            <asp:Button ID="btSearch" runat="server" Text="Search" OnClick="btSearch_Click" />
            <asp:Button ID="btClearSearch" runat="server" Text="Clear" OnClick="btClearSearch_Click" />                
        </div>
        <div class="div-box">
            <span>Clients</span>
            <prt:showfootergridview ID="gvClient" runat="server" DataSourceID="dsClient"
                AutoGenerateColumns="False" DataKeyNames="ClientID" Width="100%" 
                ShowFooter="True" ShowFooterWhenEmpty="True" ShowHeaderWhenEmpty="True" 
                OnSelectedIndexChanged="gvClient_SelectedIndexChanged" AllowPaging="True" PageSize="10"
                CssClass="GridViewStyle">
                <HeaderStyle CssClass="HeaderStyle" />
                <PagerStyle CssClass="PagerStyle" />
                <RowStyle CssClass="RowStyle" />
                <SelectedRowStyle CssClass="SelectedRowStyle" />
                <EditRowStyle CssClass="RowStyle" />
                <Columns>
                    <asp:TemplateField ShowHeader="False" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:ImageButton ID="btSelect" runat="server" CausesValidation="False" CommandName="Select" ImageUrl="~/images/rt.gif" />
                        </ItemTemplate>
                        <EditItemTemplate>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ShowHeader="false" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:ImageButton ID="btEdit" runat="server" CausesValidation="False" CommandName="Edit" ImageUrl="~/images/edit.gif" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:ImageButton ID="btUpdate" runat="server" CausesValidation="False" CommandName="Update" ImageUrl="~/images/update.gif" />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Name" SortExpression="Name">
                        <EditItemTemplate>
                            <asp:TextBox ID="tbName" runat="server" Text='<%# Bind("Name") %>' Width="97%" />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lbName" runat="server" Text='<%# Eval("Name") %>' />
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="tbName_Insert" runat="server" Width="97%" />
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Number" SortExpression="Number" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Label ID="lbNumber" runat="server" Text='<%# Eval("Number") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <ew:NumericBox ID="tbNumber" runat="server" Text='<%# Bind("Number") %>' MaxLength="5" Width="3em" />
                        </EditItemTemplate>
                        <FooterTemplate>
                            <ew:NumericBox ID="tbNumber_Insert" runat="server" MaxLength="5" Width="3em" />
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Ext" SortExpression="Extension" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Label ID="lbExtension" runat="server" Text='<%# Eval("Extension") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <ew:NumericBox ID="tbExtension" runat="server" Text='<%# Bind("Extension") %>' MaxLength="6" Width="4em" />
                        </EditItemTemplate>
                        <FooterTemplate>
                            <ew:NumericBox ID="tbExtension_Insert" runat="server" MaxLength="6" Width="4em" />
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Type" SortExpression="ClientTypeID" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                        <EditItemTemplate>
                            <asp:DropDownList ID="ddClientType" runat="server" DataSourceID="dsClientType" DataTextField="Description" DataValueField="ClientTypeID" SelectedValue='<%# Bind("ClientTypeID") %>' AppendDataBoundItems="true">
                                <asp:ListItem Value="" Text="-SELECT-" />
                            </asp:DropDownList>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lbClientType" runat="server" Text='<%# Eval("ClientType.Description") %>' />
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:DropDownList ID="ddClientType_Insert" runat="server" DataSourceID="dsClientType" DataTextField="Description" DataValueField="ClientTypeID" AppendDataBoundItems="true">
                                <asp:ListItem Value="" Text="-SELECT-" />
                            </asp:DropDownList>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Website" SortExpression="website">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("website") %>' Width="97%" />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label3" runat="server" Text='<%# Eval("website") %>' />
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="tbWebsite_Insert" runat="server" Width="97%" />
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ShowHeader="false" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:ImageButton ID="btDelete" runat="server" CausesValidation="False" CommandName="Delete" ImageUrl="~/images/delete.gif" OnClientClick="return confirm('This will delete this client and ALL associated data. Are you sure???');" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:ImageButton ID="btCancel" runat="server" CausesValidation="False" CommandName="Cancel" ImageUrl="~/images/cancel.gif" />
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:ImageButton ID="btClientInsert" runat="server" CausesValidation="False" ImageUrl="~/images/add.gif" OnClick="btClientInsert_Click" />
                        </FooterTemplate>                       
                    </asp:TemplateField>
                </Columns>
            </prt:showfootergridview>        
        </div>        
        <div class="div-box">
            <span>Greeting</span><br />
            <asp:Label ID="lbGreeting" runat="server" />
            <asp:ImageButton ID="btEditGreeting" runat="server" CausesValidation="false"  ImageUrl="~/images/edit.gif" Visible="false" />                
            <ajax:modalpopupextender ID="mpEditGreeting" runat="server" 
                PopupControlID="pnEditGreeting" TargetControlID="btEditGreeting" 
                CancelControlID="btCancelGreeting" />
            <asp:Panel ID="pnEditGreeting" runat="server" Style="display:none">
                <div class="div-box" style="width:400px; border:solid 1px Black">
                    <p style="text-align:center">Edit Client Greeting</p>
                    <p>$AMPM = Time of Day<br />
                    $OPER = Operator's First Name<br />
                    </p>
                    <asp:HiddenField ID="hfGreetingClientID" runat="server" />
                    <asp:TextBox ID="tbEditGreeting" runat="server" TextMode="MultiLine" Width="97%" Height="200px" />
                    <asp:ImageButton ID="btUpdateGreeting" runat="server" CausesValidation="false" ImageUrl="~/images/update.gif" OnClick="btUpdateGreeting_Click" />
                    &nbsp;<asp:ImageButton ID="btCancelGreeting" runat="server" ImageUrl="~/images/cancel.gif" />
                </div>
            </asp:Panel>
        </div>
        <div class="div-box">
            <span>General Instructions</span><br />
            <asp:Label ID="lbInstructions" runat="server" />
            <asp:ImageButton ID="btEditInstructions" runat="server" CausesValidation="false"  ImageUrl="~/images/edit.gif" Visible="false" />                
            <ajax:modalpopupextender ID="mpEditInstructions" runat="server" 
                PopupControlID="pnEditInstructions" TargetControlID="btEditInstructions" 
                CancelControlID="btCancelInstructions" />
            <asp:Panel ID="pnEditInstructions" runat="server" Style="display:none">
                <div class="div-box" style="width:400px; border:solid 1px Black">
                    <p style="text-align:center">Edit General Instructions</p>
                    <asp:HiddenField ID="hfInstructionsClientID" runat="server" />
                    <asp:TextBox ID="tbEditInstructions" runat="server" TextMode="MultiLine" Width="97%" Height="200px" />
                    <asp:ImageButton ID="btUpdateInstructions" runat="server" CausesValidation="false" ImageUrl="~/images/update.gif" OnClick="btUpdateInstructions_Click" />
                    &nbsp;<asp:ImageButton ID="btCancelInstructions" runat="server" ImageUrl="~/images/cancel.gif" />
                </div>
            </asp:Panel>
        </div>
        <div class="div-box">
            <span>Specific Instructions</span>
            <asp:DetailsView ID="dvSpecificInstructions" runat="server" DataSourceID="dsSpecificInstructions" DataKeyNames="SpecificInstructionID" AutoGenerateRows="False" AllowPaging="True" Visible="False" Width="100%">
                <Fields>
                    <asp:TemplateField ShowHeader="False">
                        <EditItemTemplate>
                            <asp:ImageButton ID="btUpdate" runat="server" CausesValidation="False" CommandName="Update" ImageUrl="~/images/update.gif" />
                            &nbsp;&nbsp;<asp:ImageButton ID="btCancel" runat="server" CausesValidation="False" CommandName="Cancel" ImageUrl="~/images/cancel.gif" />
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:ImageButton ID="btInsert" runat="server" CausesValidation="False" CommandName="Insert" ImageUrl="~/images/add.gif" />
                            &nbsp;&nbsp;<asp:ImageButton ID="btCancel" runat="server" CausesValidation="False" CommandName="Cancel" ImageUrl="~/images/cancel.gif" />
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <asp:ImageButton ID="btEdit" runat="server" CausesValidation="False" CommandName="Edit" ImageUrl="~/images/edit.gif" />
                            &nbsp;&nbsp;<asp:ImageButton ID="btInsert" runat="server" CausesValidation="False" CommandName="New" ImageUrl="~/images/add.gif" />
                            &nbsp;&nbsp;<asp:ImageButton ID="btDelete" runat="server" CausesValidation="False" CommandName="Delete" ImageUrl="~/images/delete.gif" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="ClientID" Visible="false" />
                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                    <asp:TemplateField HeaderText="Instructions" SortExpression="Instructions">
                        <EditItemTemplate>
                            <asp:TextBox ID="tbSpecificInstructions" runat="server" TextMode="MultiLine" Text='<%# Bind("Instructions") %>' Width="97%" />
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:TextBox ID="tbSpecificInstructions_Insert" runat="server" TextMode="MultiLine" Text='<%# Bind("Instructions") %>' Width="97%" />
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lbSpecificInstructions" runat="server" Text='<%# Bind("Instructions") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Fields>
                <EmptyDataTemplate>
                    <p>This client has no specific instructions. Please click&nbsp;
                    <asp:LinkButton ID="btNoSpecificInstructions" runat="server" Text="here" CausesValidation="false" OnClick="btNoSpecificInstructions_Click" />
                    &nbsp;to create.</p>
                </EmptyDataTemplate>
            </asp:DetailsView>
        </div>        
    </div>
    <div id="right-side">
        <div class="div-box">
            <span>Numbers</span>            
            <prt:showfootergridview ID="gvEditClientNumbers" runat="server" 
                AutoGenerateColumns="False" DataSourceID="dsClientNumber" 
                DataKeyNames="NumberID" ShowFooter="True" ShowFooterWhenEmpty="False" 
                ShowHeaderWhenEmpty="True" Width="100%" OnSelectedIndexChanging="gvClientNumbers_SelectedIndexChanging">
                <HeaderStyle CssClass="HeaderStyle" />
                <RowStyle CssClass="RowStyle" />
                <SelectedRowStyle CssClass="SelectedRowStyle" />                    
                <EditRowStyle CssClass="RowStyle" />
                <Columns>
                    <asp:TemplateField ShowHeader="false">
                        <ItemTemplate>
                            <asp:ImageButton ID="btSelect" runat="server" CausesValidation="False" CommandName="Select" ImageUrl="~/images/rt.gif" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ShowHeader="False">
                         <EditItemTemplate>
                            <asp:ImageButton ID="btUpdate" runat="server" CausesValidation="False" CommandName="Update" ImageUrl="~/images/update.gif" />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:ImageButton ID="btEdit" runat="server" CausesValidation="False" CommandName="Edit" ImageUrl="~/images/edit.gif" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Type" SortExpression="NumberTypeID" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                        <EditItemTemplate>
                            <asp:DropDownList ID="ddNumberType" runat="server" DataSourceID="dsNumberType" DataValueField="NumberTypeID" DataTextField="Description"
                                SelectedValue='<%# Bind("NumberTypeID") %>' />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lbNumberType" runat="server" Text='<%# Eval("NumberType.Description") %>' />
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:DropDownList ID="ddNumberType_Insert" runat="server" DataSourceID="dsNumberType" DataValueField="NumberTypeID" DataTextField="Description" />
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Description" SortExpression="Description" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Label ID="lbDesc" runat="server" Text='<%# Eval("Description") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbDesc" runat="server" Text='<%# Bind("Description") %>' Width="6em" />
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="tbDesc_Insert" runat="server" Width="6em" />
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Number" SortExpression="Number" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                        <EditItemTemplate>
                            <ew:NumericBox ID="tbNumber" runat="server" Text='<%# Bind("Number1") %>' ValidationGroup="valPhone" Width="6em" />
                            <ajax:MaskedEditExtender ID="meNumber" runat="server" TargetControlID="tbNumber" Mask="999-999-9999" />
                            <ajax:MaskedEditValidator ID="valNumber" runat="server" ControlToValidate="tbNumber" ControlExtender="meNumber" IsValidEmpty="false" 
                                ValidationExpression="[0-9]{3}\-[0-9]{3}\-[0-9]{4}" ValidationGroup="valNumber" />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lbNumber" runat="server" Text='<%# String.Format("{0:(###) ###-####}", Convert.ToInt64(DataBinder.Eval(Container.DataItem, "Number1"))) %>' />
                        </ItemTemplate>
                        <FooterTemplate>
                            <ew:NumericBox ID="tbNumber_Insert" runat="server" Text='<%# Bind("Number1") %>' ValidationGroup="valPhone" Width="6em" />
                            <ajax:MaskedEditExtender ID="meNumber_Insert" runat="server" TargetControlID="tbNumber_Insert" Mask="999-999-9999" />
                            <ajax:MaskedEditValidator ID="valNumber_Insert" runat="server" ControlToValidate="tbNumber_Insert" ControlExtender="meNumber_Insert" IsValidEmpty="false" 
                                ValidationExpression="[0-9]{3}\-[0-9]{3}\-[0-9]{4}" ValidationGroup="valNumber" />
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Provider" SortExpression="ProviderID" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                        <EditItemTemplate>
                            <asp:DropDownList ID="ddProvider" runat="server" DataSourceID="dsProvider" DataValueField="ProviderID" DataTextField="Name" SelectedValue='<%# Bind("ProviderID") %>' AppendDataBoundItems="true">
                                <asp:ListItem Value="" Text="-N/A-" />
                            </asp:DropDownList>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lbProvider" runat="server" Text='<%# Eval("Provider.Name") %>'  />
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:DropDownList ID="ddProvider_Insert" runat="server" DataSourceID="dsProvider" DataValueField="ProviderID" DataTextField="Name" AppendDataBoundItems="true">
                                <asp:ListItem Value="" Text="-N/A-" />
                            </asp:DropDownList>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="DID" SortExpression="DID" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                        <EditItemTemplate>
                            <asp:CheckBox ID="cbDID" runat="server" Checked='<%# Bind("DID") %>' />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="cbDID" runat="server" Checked='<%# Eval("DID") %>' Enabled="false" />
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:CheckBox ID="cbDID_Insert" runat="server" />
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton ID="btDelete" runat="server" CausesValidation="False" CommandName="Delete" ImageUrl="~/images/delete.gif" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:ImageButton ID="btCancel" runat="server" CausesValidation="False" CommandName="Cancel" ImageUrl="~/images/cancel.gif" />                            
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:ImageButton ID="btClientNumberInsert" runat="server" CausesValidation="False" ImageUrl="~/images/add.gif" OnClick="btClientNumberInsert_Click" />
                        </FooterTemplate>
                    </asp:TemplateField>
                </Columns>
            </prt:showfootergridview>
            <asp:FormView ID="fvClientNumbers" runat="server" DataKeyNames="NumberID" DataSourceID="dsClientNumber" Width="100%">
                <ItemTemplate>
                    <table width="100%">
                        <tr>
                            <td>
                                Caller Name:
                                <prt:DisabledCheckBoxControl ID="IncludeCallerNameCheckBox" runat="server" Checked='<%# Eval("IncludeCallerName") %>' />
                            </td>
                            <td>
                                Caller Address:
                                <prt:DisabledCheckBoxControl ID="IncludeCallerAddressCheckBox" runat="server" Checked='<%# Eval("IncludeCallerAddress") %>' />
                            </td>
                            <td>
                                Caller Number:
                                <prt:DisabledCheckBoxControl ID="IncludeCallerNumberCheckBox" runat="server" Checked='<%# Bind("IncludeCallerNumber") %>' />
                            </td>
                            <td>
                                Message:
                                <prt:DisabledCheckBoxControl ID="IncludeMessageCheckBox" runat="server" Checked='<%# Bind("IncludeMessage") %>' />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Custom Text1:
                                <prt:DisabledCheckBoxControl ID="IncludeCustomText1CheckBox" runat="server" Checked='<%# Bind("IncludeCustomText1") %>' />
                            </td>
                            <td>
                                Custom Numeric1:
                                <prt:DisabledCheckBoxControl ID="IncludeCustomNumeric1CheckBox" runat="server" Checked='<%# Bind("IncludeCustomNumeric1") %>' />
                            </td>
                            <td>
                                Custom DateTime1:
                                <prt:DisabledCheckBoxControl ID="IncludeCustomDateTime1CheckBox" runat="server" Checked='<%# Bind("IncludeCustomDateTime1") %>' />
                            </td>
                            <td>
                                Custom Bit1:
                                <prt:DisabledCheckBoxControl ID="IncludeCustomBit1CheckBox" runat="server" Checked='<%# Bind("IncludeCustomBit1") %>' />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Custom Text2:
                                <prt:DisabledCheckBoxControl ID="IncludeCustomText2CheckBox" runat="server" Checked='<%# Bind("IncludeCustomText2") %>' />
                            </td>
                            <td>
                                Custom Numeric2:
                                <prt:DisabledCheckBoxControl ID="IncludeCustomNumeric2CheckBox" runat="server" Checked='<%# Bind("IncludeCustomNumeric2") %>' />
                            </td>
                            <td>
                                Custom DateTime2:
                                <prt:DisabledCheckBoxControl ID="IncludeCustomDateTime2CheckBox" runat="server" Checked='<%# Bind("IncludeCustomDateTime2") %>' />
                            </td>
                            <td>
                                Custom Bit2:
                                <prt:DisabledCheckBoxControl ID="IncludeCustomBit2CheckBox" runat="server" Checked='<%# Bind("IncludeCustomBit2") %>' />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Custom Text3:
                                <prt:DisabledCheckBoxControl ID="IncludeCustomText3CheckBox" runat="server" Checked='<%# Bind("IncludeCustomText3") %>' />
                            </td>
                            <td>
                                Custom Numeric3:
                                <prt:DisabledCheckBoxControl ID="IncludeCustomNumeric3CheckBox" runat="server" Checked='<%# Bind("IncludeCustomNumeric3") %>' />
                            </td>
                            <td>
                                Custom DateTime3:
                                <prt:DisabledCheckBoxControl ID="IncludeCustomDateTime3CheckBox" runat="server" Checked='<%# Bind("IncludeCustomDateTime3") %>' />
                            </td>
                            <td>
                                Custom Bit3:
                                <prt:DisabledCheckBoxControl ID="IncludeCustomBit3CheckBox" runat="server" Checked='<%# Bind("IncludeCustomBit3") %>' />
                            </td>
                        </tr>
                    </table> 
                    <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
                    &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" />
                </ItemTemplate>
                <EditItemTemplate>
                    <table>
                        <tr>
                            <td>
                                CallerName:
                                <prt:CheckBoxControl ID="IncludeCallerNameCheckBox" runat="server" Checked='<%# Bind("IncludeCallerName") %>' />
                            </td>
                            <td>
                                CallerAddress:
                                <prt:CheckBoxControl ID="IncludeCallerAddressCheckBox" runat="server" Checked='<%# Bind("IncludeCallerAddress") %>' />
                            </td>
                            <td>
                                CallerNumber:
                                <prt:CheckBoxControl ID="IncludeCallerNumberCheckBox" runat="server" Checked='<%# Bind("IncludeCallerNumber") %>' />
                            </td>
                            <td>
                                Message:
                                <prt:CheckBoxControl ID="IncludeMessageCheckBox" runat="server" Checked='<%# Bind("IncludeMessage") %>' />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                CustomText1:
                                <prt:CheckBoxControl ID="IncludeCustomText1CheckBox" runat="server" Checked='<%# Bind("IncludeCustomText1") %>' />
                            </td>
                            <td>
                                CustomNumeric1:
                                <prt:CheckBoxControl ID="IncludeCustomNumeric1CheckBox" runat="server" Checked='<%# Bind("IncludeCustomNumeric1") %>' />
                            </td>
                            <td>
                                CustomDateTime1:
                                <prt:CheckBoxControl ID="IncludeCustomDateTime1CheckBox" runat="server" Checked='<%# Bind("IncludeCustomDateTime1") %>' />
                            </td>
                            <td>
                                CustomBit1:
                                <prt:CheckBoxControl ID="IncludeCustomBit1CheckBox" runat="server" Checked='<%# Bind("IncludeCustomBit1") %>' />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                CustomText2:
                                <prt:CheckBoxControl ID="IncludeCustomText2CheckBox" runat="server" Checked='<%# Bind("IncludeCustomText2") %>' />
                            </td>
                            <td>
                                CustomNumeric2:
                                <prt:CheckBoxControl ID="IncludeCustomNumeric2CheckBox" runat="server" Checked='<%# Bind("IncludeCustomNumeric2") %>' />
                            </td>
                            <td>
                                CustomDateTime2:
                                <prt:CheckBoxControl ID="IncludeCustomDateTime2CheckBox" runat="server" Checked='<%# Bind("IncludeCustomDateTime2") %>' />
                            </td>
                            <td>
                                CustomBit2:
                                <prt:CheckBoxControl ID="IncludeCustomBit2CheckBox" runat="server" Checked='<%# Bind("IncludeCustomBit2") %>' />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                CustomText3:
                                <prt:CheckBoxControl ID="IncludeCustomText3CheckBox" runat="server" Checked='<%# Bind("IncludeCustomText3") %>' />
                            </td>
                            <td>
                                CustomNumeric3:
                                <prt:CheckBoxControl ID="IncludeCustomNumeric3CheckBox" runat="server" Checked='<%# Bind("IncludeCustomNumeric3") %>' />
                            </td>
                            <td>
                                CustomDateTime3:
                                <prt:CheckBoxControl ID="IncludeCustomDateTime3CheckBox" runat="server" Checked='<%# Bind("IncludeCustomDateTime3") %>' />
                            </td>
                            <td>
                                CustomBit3:
                                <prt:CheckBoxControl ID="IncludeCustomBit3CheckBox" runat="server" Checked='<%# Bind("IncludeCustomBit3") %>' />
                            </td>
                        </tr>
                    </table>                    
                    <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
                    &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </EditItemTemplate>
            </asp:FormView>
            <asp:ValidationSummary ID="vsNumber" runat="server" ValidationGroup="valNumber" />
        </div>        
        <div class="div-box">
            <span>Email</span>
            <prt:showfootergridview ID="gvClientEmail" runat="server" 
                DataSourceID="dsClientEmail" DataKeyNames="ClientEmailID" AutoGenerateColumns="false" 
                ShowHeader="true" ShowFooter="true" ShowFooterWhenEmpty="false" 
                ShowHeaderWhenEmpty="true" Width="100%">
                <HeaderStyle CssClass="HeaderStyle" />
                <RowStyle CssClass="RowStyle" />
                <EditRowStyle CssClass="RowStyle" />                    
                <Columns>
                    <asp:TemplateField ItemStyle-HorizontalAlign="Center">
                        <EditItemTemplate>
                            <asp:ImageButton ID="btUpdate" runat="server" CausesValidation="False" CommandName="Update" ImageUrl="~/images/update.gif" />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:ImageButton ID="btEdit" runat="server" CausesValidation="False" CommandName="Edit" ImageUrl="~/images/edit.gif" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Description">
                        <ItemTemplate>
                            <asp:Label ID="lbDescription" runat="server" Text='<%# Eval("Description") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbDescription" runat="server" Text='<%# Bind("Description") %>' Width="97%" />
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="tbDescription_Insert" runat="server" Width="97%" />
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField  HeaderText="Address">
                        <ItemTemplate>
                            <asp:Label ID="lbAddress" runat="server" Text='<%# Eval("Address") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbAddress" runat="server" Text='<%# Bind("Address") %>' Width="97%" ValidationGroup="valEmail" />
                            <asp:RegularExpressionValidator ID="valAddress" runat="server" ControlToValidate="tbAddress" ValidationGroup="valEmail"
                                ValidationExpression="^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$" />
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="tbAddress_Insert" runat="server" Width="97%" ValidationGroup="valEmail" />
                            <asp:RegularExpressionValidator ID="valAddress" runat="server" ControlToValidate="tbAddress_Insert" ValidationGroup="valEmail" 
                                ValidationExpression="^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$" />
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:ImageButton ID="btDelete" runat="server" CausesValidation="False" CommandName="Delete" ImageUrl="~/images/delete.gif" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:ImageButton ID="btCancel" runat="server" CausesValidation="False" CommandName="Cancel" ImageUrl="~/images/cancel.gif" />                            
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:ImageButton ID="btClientEmailInsert" runat="server" CausesValidation="False" ImageUrl="~/images/add.gif" OnClick="btClientEmailInsert_Click" />
                        </FooterTemplate>                    
                    </asp:TemplateField>
                </Columns>
            </prt:showfootergridview>
            <asp:ValidationSummary ID="vsEmail" runat="server" ValidationGroup="valEmail" />
        </div>
        <div class="div-box">
            <span>Custom Fields</span>
            <prt:showfootergridview ID="gvCustomFields" runat="server" DataSourceID="dsCustomFields" DataKeyNames="ClientCustomFieldID" AutoGenerateColumns="False" 
                ShowHeader="true" ShowFooter="true" ShowFooterWhenEmpty="false" ShowHeaderWhenEmpty="true" Width="100%">
                <HeaderStyle CssClass="HeaderStyle" />
                <RowStyle CssClass="RowStyle" />
                <EditRowStyle CssClass="RowStyle" />                    
                <Columns>
                    <asp:TemplateField ShowHeader="false" ItemStyle-HorizontalAlign="Center">
                        <EditItemTemplate>
                            <asp:ImageButton ID="btUpdate" runat="server" CausesValidation="False" CommandName="Update" ImageUrl="~/images/update.gif" />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:ImageButton ID="btEdit" runat="server" CausesValidation="False" CommandName="Edit" ImageUrl="~/images/edit.gif" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Data Column" SortExpression="FieldColumnID">
                        <EditItemTemplate>
                            <asp:DropDownList ID="ddFieldColumn" runat="server" DataSourceID="dsFieldColumn" DataTextField="FieldName" DataValueField="FieldColumnID" SelectedValue='<%# Bind("FieldColumnID") %>' />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("FieldColumn.FieldName") %>'></asp:Label>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:DropDownList ID="ddFieldColumn_Insert" runat="server" DataSourceID="dsFieldColumn" DataTextField="FieldName" DataValueField="FieldColumnID"/>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Field Name" SortExpression="Name">
                        <ItemTemplate>
                            <asp:Label ID="lbFieldName" runat="server" Text='<%# Eval("Name") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbFieldName" runat="server" Text='<%# Bind("Name") %>' />
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="tbFieldName_Insert" runat="server" />
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:ImageButton ID="btDelete" runat="server" CausesValidation="False" CommandName="Delete" ImageUrl="~/images/delete.gif" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:ImageButton ID="btCancel" runat="server" CausesValidation="False" CommandName="Cancel" ImageUrl="~/images/cancel.gif" />                            
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:ImageButton ID="btCustomFieldInsert" runat="server" CausesValidation="False" ImageUrl="~/images/add.gif" OnClick="btCustomFieldInsert_Click" />
                        </FooterTemplate>
                    </asp:TemplateField>
                </Columns>
            </prt:showfootergridview>
        </div>
    </div>

    <asp:LinqDataSource ID="dsClient" runat="server" ContextTypeName="AnsweringServiceDataContext" TableName="Clients" EnableDelete="True" EnableUpdate="True" />
    <asp:LinqDataSource ID="dsClientType" runat="server" ContextTypeName="AnsweringServiceDataContext" TableName="ClientTypes" Select="new (Description, ClientTypeID)" />
    <asp:LinqDataSource ID="dsClientNumber" runat="server" ContextTypeName="AnsweringServiceDataContext" TableName="Numbers" EnableDelete="True" EnableUpdate="True"
        Where="ClientID == @ClientID" OnSelecting="LinqDataSource_Selecting">
        <WhereParameters>
            <asp:ControlParameter ControlID="gvClient" Name="ClientID" PropertyName="SelectedValue" Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="dsNumberType" runat="server" ContextTypeName="AnsweringServiceDataContext" TableName="NumberTypes" Select="new (NumberTypeID, Description)" />
    <asp:LinqDataSource ID="dsProvider" runat="server" ContextTypeName="AnsweringServiceDataContext" TableName="Providers" Select="new (ProviderID, Name)" />    
    <asp:LinqDataSource ID="dsClientEmail" runat="server" ContextTypeName="AnsweringServiceDataContext" TableName="Emails" EnableDelete="True" EnableUpdate="True" 
        Where="ClientID == @ClientID" OnSelecting="LinqDataSource_Selecting">
        <WhereParameters>
            <asp:ControlParameter ControlID="gvClient" Name="ClientID" PropertyName="SelectedValue" Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="dsClientDetail" runat="server" ContextTypeName="AnsweringServiceDataContext" TableName="Clients" EnableUpdate="True" 
        Where="ClientID == @ClientID" OnSelecting="LinqDataSource_Selecting">
        <WhereParameters>
            <asp:ControlParameter ControlID="gvClient" Name="ClientID" PropertyName="SelectedValue" Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="dsSpecificInstructions" runat="server" ContextTypeName="AnsweringServiceDataContext" TableName="SpecificInstructions"
        EnableDelete="True" EnableInsert="True" EnableUpdate="True" Where="ClientID == @ClientID" OnSelecting="LinqDataSource_Selecting">
        <WhereParameters>
            <asp:ControlParameter ControlID="gvClient" Name="ClientID" PropertyName="SelectedValue" Type="Int32" />
        </WhereParameters>
        <InsertParameters>
            <asp:ControlParameter ControlID="gvClient" Name="ClientID" PropertyName="SelectedValue" Type="Int32" />
        </InsertParameters>
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="dsCustomFields" runat="server" ContextTypeName="AnsweringServiceDataContext" TableName="CustomFields" EnableDelete="True" EnableUpdate="True" 
        Where="ClientID == @ClientID" OnSelecting="LinqDataSource_Selecting">
        <WhereParameters>
            <asp:ControlParameter ControlID="gvClient" Name="ClientID" PropertyName="SelectedValue" Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>  
    <asp:LinqDataSource ID="dsFieldColumn" runat="server" ContextTypeName="AnsweringServiceDataContext" TableName="FieldColumns" />
</asp:Content>
